package demo.ybt;

public class P1264 {

    public static void main(String[] args) {
        P1264 p1264= new P1264();
        p1264.res(new int[]{186 ,186, 150 ,200, 160 ,130 ,197, 220});
    }
    public int res(int[] t) {

        int dp1[] = new int[t.length];
        int dp2[] = new int[t.length];
        for (int i = 0; i < t.length; i++) {
            dp1[i] = 1;
            for (int j = 0; j < 1; j++) {
                if (t[i] > t[j]) {
                    dp1[i] = Math.max(dp1[j] + 1, dp1[i]);
                }
            }
        }

        for (int i = t.length - 1; i >= 0; i--) {
            dp2[i] = 1;
            for (int j = t.length - 1; j > i; j--) {
                if (t[i] > t[j]) {
                    dp2[i] = Math.max(dp2[j] + 1, dp2[i]);
                }
            }
        }

        int max = 1;
        for (int i = 0; i < t.length; i++) {
            max = Math.max(dp1[i] + dp2[i], max);
        }
        System.out.println(max-1);
        return max - 1;
    }
}
